import { defineStore } from 'pinia';

export const usePaymentStore = defineStore('payment', {
    state: () => ({
        isPaymentSuccess: false,
        outTradeNo: null,
        codeUrl: null // 新增：用于保存 code_url
    }),
    actions: {
        setPaymentSuccess(success) {
            this.isPaymentSuccess = success;
        },
        setOutTradeNo(tradeNo) {
            this.outTradeNo = tradeNo;
        },
        setCodeUrl(url) {
            this.codeUrl = url; // 新增：设置 code_url 的方法
        }
    },
    getters: {
        getPaymentStatus: (state) => state.isPaymentSuccess,
        getCodeUrl: (state) => state.codeUrl // 新增：获取 code_url 的 getter
    }
});